home *** CD-ROM | disk | FTP | other *** search
- /*
- TWINCLIP.C
- Test WinClip -- non-Windows program reads Windows clipboard
-
- NOTE: I originally wrote this as a sample program for
- 286|DOS-Extender, a new product from Phar Lap Software.
- 286|DOS-Extender runs protected-mode programs, produced with the
- Microsoft C -Lp switch, under MS-DOS. However, if you compile
- for real mode, this also stands as an example of using the
- Windows Clipboard services (INT 2Fh AH=17h). Call me if you
- have any questions:
- Andrew Schulman
- Phar Lap Software
- (617) 661-1510 x238
- andrew@pharlap.com
- CIS 76320,302
-
- Documentastion for these services is available in INTRLIST, a
- hypertext database of interrupts and functions that accompanies the
- book _Undocumented DOS: A Programmer's Guide to Reserved MS-DOS
- Functions and Data Structures_, edited by Andrew Schulman (Reading
- MA: Addison-Wesley, 1990, 694 pages, ISBN 0-201-57064-5, $39.95). If
- you can't find the book in your local bookstore, call Addison-Wesley
- at 617-944-3700, and order it from them.
-
- SEE ALSO WINCLIP.C, PWINCLIP.C, WINCLIP.H
-
- TWINCLIP.C -- test file; no change needed for 286|DOS-Extender
- WINCLIP.H -- header file for Windows API for DOS apps
- WINCLIP.C -- real mode implementation of API
- PWINCLIP.C -- protected mode implementation of API
-
- real mode:
- C:\>cl twinclip.c winclip.c
- C:\>\win30\win /e
- within Windows DOS box:
- C:\>twinclip
-
- protected mode:
- C:\>cl -Lp twinclip.c pwinclip.c
- C:\>\win30\win /e
- with Windows DOS box:
- C:\>run286 twinclip
-
- sample output:
- WINOLDAP v. 2.0
- Resolution: 640 x 480 (16 colors)
- Clipboard data: 1248 bytes
- Clipboard contents:
- ... [contents of clipboard]
- */
-
- #include <stdlib.h>
- #include <stdio.h>
-
- #include "winclip.h"
-
- void fail(char *s) { puts(s); exit(1); }
-
- int main(int argc, char *argv[])
- {
- unsigned long size;
- char far *buf;
- int maj, min;
-
- if (WinOldApVersion(&maj, &min))
- printf("WINOLDAP v. %d.%d\n", maj, min);
- else
- fail("This program requires WINOLDAP");
-
- printf("Resolution: %u x %u (%u colors)\n",
- GetDeviceCaps(HORZRES), GetDeviceCaps(VERTRES),
- GetDeviceCaps(NUMCOLORS));
-
- OpenClipboard();
-
- if (! (size = GetClipboardSize(CF_TEXT)))
- puts("No text in clipboard");
- else if (buf = GetClipboardData(CF_TEXT))
- {
- printf("Clipboard data: %lu bytes\n", size);
- printf("Clipboard contents:\n%Fs\n", buf); /* Far string */
- FreeClipboardData(buf);
- }
-
- CloseClipboard();
-
- return 0;
- }
-
-